<?php
//
///*
//|--------------------------------------------------------------------------
//| Web Routes
//|--------------------------------------------------------------------------
//|
//| Here is where you can register web routes for your application. These
//| routes are loaded by the RouteServiceProvider within a group which
//| contains the "web" middleware group. Now create something great!
//|
//*/
//
Route::get('/', function () {
    return view('welcome');
});

//////单响应
////Route::get('hello',function() {
////    return view('hello');
////});
//////
//////Route::get('/user', 'UserController@index');
//////Route::post('/user', 'UserController@index');
//////Route::put('/user',  'UserController@index');
//////Route::patch('/user','UserController@index');
//////Route::delete('/user', 'UserController@index');
//////Route::options('/user', 'UserController@index');
//////
//////
////////多匹配
//////Route::match(['get','post'],'/',function () {
//////    //
//////});
//////
//////Route::any('user', function () {
//////    //
//////});
////
////
//////重定向路由
////Route::redirect('/welcome','/hello',301);
////
////
//////路由参数
//////单参数
////Route::get('user/{id}', function ($id) {
////    return $id;
////});
//////多参数
////Route::get('name/{name}/age/{age}', function ($name, $age)
////{
////   return $name.$age;
////});
//////可选参数
//////Route::get('name/{name?}', function ($name = 'wubicheng') {
//////    return $name;
//////});
////
//////正则表达式约束
////Route::get('name/{name}', function ($name) {
////    return $name;
////})->where('name', '[A-Za-z]');
////
////Route::get('phone/{phone}', function ($phone) {
////    return $phone;
////})->where('phone','[0-9]+');
////
//////全局约束,在app/providers/routeServiceProvider中的boot中编写
////Route::get('user/{id}',function ($id) {
////    return $id;
////});
////
//////路由命名
////Route::get('user/profile', function () {
////    return 'route rename';
////})->name('profile');
////
//////命名后生成链接，重定向到该路由
////$url= route('profile');
////return redirect()->route('profile');
////
/////*
//// * 检查当前路由
//// *
//// * if($request->route()->name('profile')
//// */
////
/////*
//// * 路由组
//// * 定义：允许在路由之间共享属性，例如中间件和命名空间
//// */
////
//////中间件
////Route::middleware(['first,second'])->group(function () {
////    Route::get('/', function () {
////        //使用first和second中间件
////    });
////
////    Route::get('user/profile', function () {
////        //使用first 和 second中间件
////    });
////});
////
//////命名空间
////Route::namespace('Admin')->group(function () {
////    //在'App\Http\Controller\Admin'命名空间下的控制器
////});
////
////
//////子域名路由
////Route::domain('{account}.myapp.com')->group(function () {
////   Route::get('user/{$id}', function ($account, $id) {
////
////   });
////});
////
//////路由前缀
////Route::prefix('admin')->group(function () {
////    Route::get('users', function () {
////        //匹配包含'/admin/users'的url
////    });
////});
////
//////路由模型绑定(隐式绑定)
////Route::get('api/users/{user}', function (App\User $user) {
////    return $user->email;
////});
////
//////自定义解析模型
/////*
//// * public function boot()
//// * {
//// *      parent::boot();
//// *      Route::bind('user', function ($value) {
//// *      return App\User::where('name',$value)->first();
//// * });
//// */
////
//////访问当前路由
////$route = Route::current();
////$name = Route::currentRouteName();
////$action = Route::currentRouteAction();
//
//
//
////多个路由使用同一个中间件
//Route::group(['middleware' => 'check'],function () {
//    Route::get('user/index/{age}','UserController@index');
//    //Route::get('user/show/{age}', 'UserController@show');
//});
//
//
////Route::get('user/show/{age}',function ($age) {
////   return 'h';
////})->middleware('check');
//
//Route::get('hello','UserController@hello');
//
////中间件组，一个路由使用多个中间件
//Route::group(['middle'=>['web']], function () {
//    //
//});
//
////中间件参数,使用场景：用户权限认证
//Route::put('post/{id}', function ($id) {
//    //
//})->middleware('role:edit');
//
//Route::get('user/csrf','UserController@csrf');
////数据库的原生操作和查询构造器的使用
//Route::get('user/index','UserController@index');
//Route::get('user/add','UserController@add');
//Route::get('user/update', 'UserController@update');
//Route::get('user/delete', 'UserController@delete');
//
////orm模型的使用
//Route::get('flight/index','FlightController@index');
//Route::get('flight/add','FlightController@add');
//Route::get('flight/update','FlightController@update');
//Route::get('flight/delete', 'FlightController@delete');
//
////require_once './admin/web.php';
//Route::namespace('admin')->group(function () {
//   //在App\Http\Controllers\Admin吗，命名空间下的控制器
//    Route::get('index','StudentController@index');
//});
//
//Route::get('blade', function () {
//   return view('layouts/child');
//});
//
//Route::get('alert', function () {
//    return view('alert');
//});
//
////Route::get('hello',function () {
////    return view('hello');
////});
//
//Route::get('csrf', function () {
//    return view('csrf');
//});
//
////require_once __DIR__.'/admin/web.php';
////用户认证路由
//Auth::routes();
//Route::get('/home', 'HomeController@index')->name('home');
////路由中间件，只允许通过认证的用户访问指定的路由
//Route::get('profile',function () {
//    return 'pass auth';
//})->middleware('auth');
////使用路由组，把只允许登录后才能进行的操作放到里面去
////Route::group();
//
Route::get('admin/create','ArticleController@create');
//使用post提交表单
Route::post('admin/create','ArticleController@store');
//文件操作路由
Route::get('file','ArticleController@fileCommand');
Route::get('upload','UploadFileController@uploadForm');
Route::post('upload','UploadFileController@upload');
Route::get('showfile','UploadFileController@show');

//生成验证码
Route::get('captcha/{tmp}','CaptchaController@captcha');
//带验证码的表单
Route::get('captchaForm', 'CaptchaController@captchaForm');
//验证注册码
Route::post('verify','CaptchaController@verifyCaptcha');

//获取关联模型相关的路由
Route::namespace('Admin')->group(function () {
    Route::get('post/index','PostController@index');
    Route::get('comment/index','CommentController@index');
    //这个页面中的路由需要csrf验证
    //Route::post('user/index','UserController@index');
    Route::get('role/index','RoleController@index');

    //事件监听测试
    Route::get('post/update','PostController@update');

});

//前台模块
Route::group([
    'namespace' => 'home',
    'as'        => 'home',
    //'prefix'    => 'home',
],function () {
    Route::get('home/index','IndexController@index');
});


//image插件的使用
Route::post('image/index','ImageController@index');
Route::get('fileForm', 'ImageController@fileForm');